using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace InputTeclado
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        private Texture2D nave;
        private Vector2 posicaoXY;
        private const float velocidade = .4f;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        
        protected override void Initialize()
        {
           

            base.Initialize();
        }

        protected override void LoadContent()
        {
            
            spriteBatch = new SpriteBatch(GraphicsDevice);

            nave = Content.Load<Texture2D>("nave");

         }

        protected override void UnloadContent()
        {
            
        }

       
        protected override void Update(GameTime gameTime)
        {
            KeyboardState keyBoard = Keyboard.GetState();

            float desloc = (float)gameTime.ElapsedGameTime.TotalMilliseconds * velocidade;

            if (keyBoard.IsKeyDown(Keys.Left))
            {
                posicaoXY.X -= desloc;
            }
            if (keyBoard.IsKeyDown(Keys.Right))
            {
                posicaoXY.X += desloc;
            }
            if (keyBoard.IsKeyDown(Keys.Up))
            {
                posicaoXY.Y -= desloc;
            }
            if (keyBoard.IsKeyDown(Keys.Down))
            {
                posicaoXY.Y += desloc;
            }

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();

            spriteBatch.Draw(nave, posicaoXY, Color.White);

            spriteBatch.End();
           
            base.Draw(gameTime);
        }
    }
}
